load("@rules_java//java:defs.bzl", "java_library")
load("//:cel_android_rules.bzl", "cel_android_library")

package(
    default_applicable_licenses = ["//:license"],
    default_visibility = [
        "//common:__pkg__",
        "//publish:__pkg__",
    ],
)

# keep sorted
COMPILER_COMMON_SOURCES = [
    "CelFunctionDecl.java",
    "CelIssue.java",
    "CelOverloadDecl.java",
    "CelValidationException.java",
    "CelValidationResult.java",
    "CelVarDecl.java",
]

# keep sorted
SOURCE_SOURCES = [
    "CelSourceHelper.java",
    "Source.java",
]

# keep sorted
PROTO_AST_SOURCE = [
    "CelProtoAbstractSyntaxTree.java",
]

# keep sorted
PROTO_V1ALPHA1_AST_SOURCE = [
    "CelProtoV1Alpha1AbstractSyntaxTree.java",
]

java_library(
    name = "cel_descriptors",
    srcs = [
        "CelDescriptorUtil.java",
        "CelDescriptors.java",
    ],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "//common/internal:file_descriptor_converter",
        "//common/types:cel_types",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "compiler_common",
    srcs = COMPILER_COMMON_SOURCES,
    tags = [
    ],
    deps = [
        ":cel_ast",
        ":cel_exception",
        ":cel_source",
        ":source",
        ":source_location",
        "//:auto_value",
        "//common/annotations",
        "//common/internal:safe_string_formatter",
        "//common/types:cel_proto_types",
        "//common/types:type_providers",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:org_jspecify_jspecify",
    ],
)

java_library(
    name = "cel_exception",
    srcs = ["CelException.java"],
    # used_by_android
    tags = [
    ],
    deps = [
        ":error_codes",
    ],
)

java_library(
    name = "options",
    srcs = ["CelOptions.java"],
    # used_by_android
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

java_library(
    name = "proto_ast",
    srcs = PROTO_AST_SOURCE,
    tags = [
    ],
    deps = [
        ":cel_ast",
        ":cel_source",
        "//common/ast:expr_converter",
        "//common/types:cel_proto_types",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@cel_spec//proto/cel/expr:syntax_java_proto",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "proto_ast_android",
    srcs = PROTO_AST_SOURCE,
    tags = [
    ],
    deps = [
        ":cel_ast_android",
        ":cel_source_android",
        "//common/ast:expr_converter_android",
        "//common/types:cel_proto_types_android",
        "@cel_spec//proto/cel/expr:checked_java_proto_lite",
        "@cel_spec//proto/cel/expr:syntax_java_proto_lite",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
    ],
)

java_library(
    name = "proto_v1alpha1_ast",
    srcs = PROTO_V1ALPHA1_AST_SOURCE,
    tags = [
    ],
    deps = [
        ":cel_ast",
        ":cel_source",
        "//common/ast:expr_v1alpha1_converter",
        "//common/types:cel_v1alpha1_types",
        "@com_google_googleapis//google/api/expr/v1alpha1:expr_java_proto",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "error_codes",
    srcs = ["CelErrorCode.java"],
    # used_by_android
    tags = [
    ],
)

java_library(
    name = "runtime_exception",
    srcs = ["CelRuntimeException.java"],
    # used_by_android
    tags = [
    ],
    deps = [
        ":error_codes",
        "//common/annotations",
    ],
)

java_library(
    name = "mutable_ast",
    srcs = ["CelMutableAst.java"],
    tags = [
    ],
    deps = [
        ":cel_ast",
        ":mutable_source",
        "//common/ast",
        "//common/ast:mutable_expr",
        "//common/types:type_providers",
    ],
)

java_library(
    name = "mutable_source",
    srcs = ["CelMutableSource.java"],
    tags = [
    ],
    deps = [
        ":cel_source",
        "//:auto_value",
        "//common/ast:mutable_expr",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "proto_json_adapter",
    srcs = ["CelProtoJsonAdapter.java"],
    tags = [
    ],
    deps = [
        "//common/internal:proto_time_utils",
        "//common/values",
        "//common/values:cel_byte_string",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "source_location",
    srcs = ["CelSourceLocation.java"],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "cel_source",
    srcs = ["CelSource.java"],
    tags = [
    ],
    deps = [
        ":source",
        ":source_location",
        "//:auto_value",
        "//common/annotations",
        "//common/ast",
        "//common/internal",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "cel_source_android",
    srcs = ["CelSource.java"],
    tags = [
    ],
    deps = [
        ":source_android",
        ":source_location_android",
        "//:auto_value",
        "//common/ast:ast_android",
        "//common/internal:internal_android",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
    ],
)

java_library(
    name = "cel_ast",
    srcs = ["CelAbstractSyntaxTree.java"],
    tags = [
    ],
    deps = [
        ":cel_source",
        "//:auto_value",
        "//common/annotations",
        "//common/ast",
        "//common/types",
        "//common/types:type_providers",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "cel_ast_android",
    srcs = ["CelAbstractSyntaxTree.java"],
    tags = [
    ],
    deps = [
        ":cel_source_android",
        "//:auto_value",
        "//common/annotations",
        "//common/ast:ast_android",
        "//common/types:type_providers_android",
        "//common/types:types_android",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
    ],
)

java_library(
    name = "source",
    srcs = SOURCE_SOURCES,
    tags = [
    ],
    deps = [
        ":source_location",
        "//common/annotations",
        "//common/internal",
        "@maven//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "source_android",
    srcs = SOURCE_SOURCES,
    visibility = ["//visibility:private"],
    deps = [
        ":source_location_android",
        "//common/annotations",
        "//common/internal:internal_android",
        "@maven_android//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "source_location_android",
    srcs = ["CelSourceLocation.java"],
    visibility = ["//visibility:private"],
    deps = [
        "//:auto_value",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
    ],
)

java_library(
    name = "container",
    srcs = ["CelContainer.java"],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)
